package com.ruoyi.common.utils;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 订单编号生成
 */
public class OrderIdGenerator {

    public static String generateOrderId(Long orderId) {
        String datePart = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
        String orderNum = datePart + String.valueOf(orderId).substring(String.valueOf(orderId).length() - 10);
        return orderNum;
    }

    public static void main(String[] args) {
        // 测试生成多个订单编号
        System.out.println(generateOrderId(1852767966076280834L));
    }
}
